package ACM_Brush;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Solution128 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int length = in.nextInt();
        int[] array = new int[length];
        for (int i = 0; i < length; i++) {
            array[i] = in.nextInt();
        }
        System.out.printf("%d", new mySolution().method(array));
        in.close();
        ;
    }
}

class mySolution {
    public int method(int[] array) {
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < array.length; i++)
            set.add(array[i]);
        int result = 0;
        for (int i = 0; i < array.length; i++) {
            if (!set.contains(array[i] - 1)) {
                int sequenceLen = 0;
                int start = array[i];
                while (set.contains(start)) {
                    sequenceLen++;
                    start++;
                }
                result = Math.max(result, sequenceLen);
            } else
                continue;
        }
        return result;
    }
}